﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace SharpWeb
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var item in GetRoutes())
            {
                routes.Add(item);
            }
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new RouteDescriptor[] { 
            new RouteDescriptor {
                Route = new Route(
                "Dashboard",
                new RouteValueDictionary {//默认值
                                            {"area", "SharpWeb.Dashboard"},
                                            {"controller", "Home"},
                                            {"action", "Index"}
                                        },
                new RouteValueDictionary(),//约束
                new RouteValueDictionary {//数据标记
                                            {"area", "SharpWeb.Dashboard"}
                                        },
                new MvcRouteHandler()//用于处理路由请求
                )
        }
            };
        }
    }
}